Imports


In [56]:
from owslib.wms import WebMapService
import matplotlib.pyplot as plt
import matplotlib.image as mpimg
from ipywidgets import widgets,interact

Load Web Map Service


In [57]:
wms=WebMapService('http://mapy.geoportal.gov.pl/wss/service/img/guest/Administracyjna/MapServer/WMSServer')

Please provide a bounding box (comma separated) longitude min, latitude min, longitude max latitude max


In [78]:
from IPython.display import display
bbox=widgets.Text()
display(bbox)



In [99]:
bb=bbox.value.split(',')
bb=tuple([float(x) for x in bb])

Image request


In [100]:
img = wms.getmap(layers=['Administracyjna'],styles=['default'],srs='EPSG:4326',bbox=bb,size=(1800,1600),format='image/jpeg',transparent=False)

Save image locally


In [101]:
out=open('obrazek.jpg','wb')

In [102]:
out.write(img.read())
out.close()

Display image


In [103]:
obr=mpimg.imread('obrazek.jpg')
imgplot = plt.imshow(obr)
plt.show()



In [ ]: